using System;
using Gtk;
using NHibernate.Cfg;
using NHibernate;

namespace PNhibernate
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			Application.Init ();
			
			Configuration configuration = new Configuration();
			configuration.Configure();
			//configuration.AddAssembly("Npgsql");
			configuration.AddAssembly("PNhibernate");
			
			ISessionFactory sessionFactory = configuration.BuildSessionFactory();
			
			ISession session = sessionFactory.OpenSession();
			
			Categoria categoria = session.Load<Categoria>(2L);
			
			Console.WriteLine("categoria.Nombre={0}", categoria.Nombre);
			
			//session.Save(categoria);
			
			IQuery query = session.CreateQuery("Select c From Categoria c");
			foreach (Categoria cat in query.Enumerable())
			{
				Console.WriteLine("Categoria: " + cat.Nombre);
			}

			
			session.Close();
			
			sessionFactory.Close();
			
			MainWindow win = new MainWindow ();
			win.Show ();
			Application.Run ();
		}
	}
}
